<extend name="layout:index"/>
<block name="content">
<body class="gray-bg">
<if condition="$time eq 1">
    <div class="wrapper wrapper-content animated fadeInRight">
      <div class="row">
	   <span style="color:red">现金积分交易时间:每天09:00~18:00</span>
      <div class="tabs-container">
		   <ul class="nav nav-tabs text-center">
		       <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true" id="a_one"  style="width:300px;background-color:white;"> 出售现金积分</a>
		       </li>
		       <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false" id="a_two" style="width:300px;">出售中的现金积分</a>
		       </li>
		   </ul>
      <div class="tab-content">
       <div id="tab-1" class="tab-pane active">
           <div class="panel-body">
			<div class="col-sm-12">
			  <div class="ibox float-e-margins">
			      <div class="ibox-content">
			          <form class="form-horizontal m-t" id="signupForm" action="__MODULE__/sell/actsellmoney" method="post" onSubmit='return checkForm(this)'>
			              <div class="form-group">
			                  <label class="col-sm-3 ">请输入出售数量</label>
			                  <div class="col-sm-8">
		                          <input id="sell_points" name="sell_points" class="form-control" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)"  type="text">
		                      </div>
	              		 </div>
	              		 <div class="form-group">
			                  <span style="color:red">当前可卖出的数量为<font id="zong">{$money1}</font>，最少卖出的数量为150(必须是50的倍数)</span>
	              		 </div>
	              <div class="form-group">
	                  <label class="col-sm-3 ">*手机验证码：</label>
	                  <div class="col-sm-8">
	                  		<div class="input-group">
                                <input id="mobile_code" name="mobile_code" class="form-control" type="text"> 
                                <span class="input-group-btn"> 
                                	<input id="btnSendCode" class="btn btn-primary" value="获取手机验证码" onclick="sendMessage()" type="button" /> 
                                </span>
                            </div>
	                  </div>
	              </div>
	              		<div class="form-group">
			                  <label class="col-sm-3 ">请输入安全密码</label>
			                  <div class="col-sm-8">
		                          <input id="repassword" name="repassword" class="form-control" type="password">
		                      </div>
	              		</div>
	              
	              		<div class="form-group">
                        <div class="col-sm-12 ">
                            <input class="btn" id="bnt4" style="background-color: #378cbe;width: 100%;height: 40px" value="出售提交"  type="submit">
                        </div>
                    </div>
			           </form>
			       </div>
			   </div>
			</div>
            </div>
        </div>
        <div id="tab-2" class="tab-pane">
            <div class="panel-body">
            <div class="col-sm-12">
			  <div class="ibox float-e-margins">
			    <div class="ibox-content">
            	<form class="form-horizontal m-t" name="aqmmform">
	              		<div class="table-responsive">
							<table class="table table-bordered table-striped table-hover">
								<thead>
									<tr>
										<th>日期</th>
										<th>交易类型</th>
										<th>数量</th>
										<th>单价</th>
										<th>总额</th>
										<th>当前状态</th>
									
										<th>交易信息</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<volist name="money" id="vo">
						 			<tr>
										<td>{:date('Y-m-d H:i:s',$vo['sell_time'])}</td>
										<td>{$vo.content}</td>
										<td>卖出{$vo.sell_num}</td>
										<td>{$param11}</td>
										<td>{$param11*$vo.sell_num}</td>

										<if condition="$vo.status eq 0">
											<td>未购买</td>
										<elseif condition="$vo.status eq 1"/>
											<td>等待付款</td>
										<elseif condition="$vo.status eq 2"/>
											<td>已付款</td>
										<elseif condition="$vo.status eq 3"/>
											<td>交易成功</td>
										<elseif condition="$vo.status eq 4"/>
											<td>已退回</td>
										<elseif condition="$vo.status eq 5"/>
											<td>预约挂卖</td>
										<elseif condition="$vo.status eq 6"/>
											<td>已撤销</td>
										</if>

									
										<td><a id="link" class="link" style="cursor: pointer;" target="_top">交易信息</a></td>
										<if condition="$vo.status eq 0">
										<td><a href="__MODULE__/sell/cancel?mk={$vo.mk_id}">撤销出售</a></td>
										<elseif condition="$vo.status eq 1"/>
										<td></td>
										<elseif condition="$vo.status eq 2"/>
										<td><a href="__MODULE__/sell/send?mk={$vo.mk_id}">发货</a></td>
										<elseif condition="$vo.status eq 3"/>
										<td></td>
										<elseif condition="$vo.status eq 4"/>
										<td></td>
										<elseif condition="$vo.status eq 5"/>
										<td></td>
										<elseif condition="$vo.status eq 6"/>
										<td></td>
										</if>
									</tr>
									</volist>
                                </tbody>
							</table>
							</div>
							<div class="">
 <div id="pager">
  <span style="margin-right:10px;">总计 <b>{$count}</b>  个记录</span>
      
      </div>

</div>
</form>
	             
	           </div>
	           </div>
	           </div>
            </div>
        </div>
   </div>
   </div>
</div>
    </div>
  <else />
  	<div color='red' >不在系统出售时间内</div>
  </if> 
   
		
<script>
	//下面的是发送手机验证码
var InterValObj; //timer变量，控制时间
var count = 30; //间隔函数，1秒执行
var curCount;//当前剩余秒数

function sendMessage() {
    curCount = count;       
       
    //向后台发送处理数据
         $.ajax({
                    type : 'POST',
                    url : '/home/sell/phoneAjax',
                    data : {code:1},
                    dataType : 'html',
                    async : false,
                    success : function(str){                       
                         if(str == '发送成功'){                            
                            //设置button效果，开始计时
                            $("#btnSendCode").attr("disabled", "true");
                            $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
                            InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
                        }else{
                               var txt=  "信息错误,请核对后再添";
                               window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.info);
                        }                        
                    }
                
                })
   
}
//timer处理函数
function SetRemainTime(){
    if (curCount == 0) {                
        window.clearInterval(InterValObj);//停止计时器
        $("#btnSendCode").removeAttr("disabled");//启用按钮
        $("#btnSendCode").val("重新发送验证码");
        code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效    
    }else {
        curCount--;
        $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
    }
}

//安全码验证
 	
	 $('#bnt4').click(function(){
	 	var a = $('#sell_points').val();
	 	var b = $('#zong').text();

	 	if(a == ''){
			var txt=  "出售数量不能为空";
			window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
			return false;
		}
		if(a>parseInt(b)){

	 		var txt=  "出售数量不能大于现金积分总数";
			window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
			return false;
	 	}
		if(a<150){
			var txt=  "出售数量不能小于最低出售现金积分";
			window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
			return false;
		}
		var c = a%50;

		if(c!=0){
			var txt=  "出售数量必须是50的倍数";
			window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
			return false;
		}



	 });


	 function checkForm(){
	 	$('.btn').attr('disabled',true);
	if($('#mobile_code').val() == ''){
		 var txt=  "验 证 码 不 能 为 空";
         window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
         return false;
	}else{
		return true;
	}
 
}
</script>
    


</body>
</block>